<template>
  <div class="box5">
    <div class="title">
      <p>未来七天游客数量趋势图</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="charts" ref="line"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

//获取图表DOM实例
let line = ref()

//组件挂载完毕
onMounted(() => {
  //初始化echarts实例
  let mycharts = echarts.init(line.value)
  //设置echarts配置项
  mycharts.setOption({
    //标题
    title: {
      text: '访问量',
    },
    //x y轴
    xAxis: {
      type: 'category', //均匀分布
      boundaryGap: false, //两侧不留白
      splitLine: {
        //分割线隐藏
        show: false,
      },
      data: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
      axisLine: {
        //轴线设置
        show: true,
      },
      axisTick: {
        //轴线刻度
        show: true,
      },
    },
    yAxis: {
      splitLine: {
        show: false,
      },
      axisLine: {
        show: true,
      },
      axisTick: {
        show: true,
      },
    },
    //位置
    grid: {
      left: 40,
      top: 0,
      right: 20,
      bottom: 20,
    },
    //系列
    series: [
      {
        type: 'line',
        data: [120, 1240, 66, 1299, 321, 890, 200],
        smooth: true, //平滑曲线的设置
        areaStyle: {
          //区域填充样式
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              { offset: 0, color: 'rgba(0, 255, 255, 0.8)' }, // 青色
              { offset: 0.5, color: 'rgba(0, 100, 255, 0.6)' }, // 深蓝
              { offset: 1, color: 'rgba(0, 0, 50, 0.3)' }, // 深邃蓝黑
            ],
            global: false,
          },
        },
      },
    ],
  })
})
</script>

<style scoped lang="scss">
.box5 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin: 0 20px;

  .title {
    margin-left: 10px;

    p {
      color: #fff;
      font-size: 20px;
    }
  }

  .charts {
    height: calc(100% - 40px);
  }
}
</style>
